package com.demo2do.fms.entity.data.business;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.demo2do.core.format.PersistentFormat;
import com.demo2do.fms.entity.authority.Organization;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 行驶公里数(汽车行驶距离)
 * 
 * @author Ysy
 */
@Entity
@Table(name = "TBL_TRUCK_FACILITY_DISTANCE")
@PersistentFormat
public class FacilityDistance {
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 行驶公里数  */
    private BigDecimal facilityDistance;
    
    /** 运输周期  */
    private Integer shipmentCycle;
    
    /** 运输公司 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "organization_id", referencedColumnName = "id")
    @PersistentFormat
    @JsonIgnore
    private Organization organization;
    
    /** 起始地  - 装卸地  */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "from_load_place_id", referencedColumnName = "id")
    @PersistentFormat
    @JsonIgnore
    private LoadPlace fromLoadPlace;
    
    /** 目的地  - 装卸地  */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "to_load_place_id", referencedColumnName = "id")
    @PersistentFormat
    @JsonIgnore
    private LoadPlace toLoadPlace;
    
    /** 创建人  */
    private Long creatorId;
    
    /** 创建时间  */
    private Date createDate;
    
    /** 最后操作人 */
    private Long lastOperatorId;
    
    /** 最后更新时间  */
    private Date lastModifyDate;

    @Column(name = "is_disabled")
    private Boolean disabled;
    
    /**
     * 
     * the default constructor
     */
    public FacilityDistance() {

    }
    
    /**
     * 
     * @param operator
     * @param now
     * @return
     */
    public FacilityDistance operator(Long operator, Date now) {
        this.lastOperatorId = operator;
        this.lastModifyDate = now;
        return this;
    }
    
    /**
     * @param operator
     * @param now
     * @return
     */
    public FacilityDistance initialize(Long operator, Date now){
        this.disabled = false;
        this.creatorId = operator;
        this.createDate = now;
        this.lastOperatorId = operator;
        this.lastModifyDate = now;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public FacilityDistance modify(){
        this.lastModifyDate = new Date();
        this.lastOperatorId = new Long(1);
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the facilityDistance
     */
    public BigDecimal getFacilityDistance() {
        return facilityDistance;
    }

    /**
     * @return the shipmentCycle
     */
    public Integer getShipmentCycle() {
        return shipmentCycle;
    }

    /**
     * @return the organization
     */
    public Organization getOrganization() {
        return organization;
    }

    /**
     * @return the fromLoadPlace
     */
    public LoadPlace getFromLoadPlace() {
        return fromLoadPlace;
    }

    /**
     * @return the toLoadPlace
     */
    public LoadPlace getToLoadPlace() {
        return toLoadPlace;
    }

    /**
     * @return the creatorId
     */
    public Long getCreatorId() {
        return creatorId;
    }

    /**
     * @return the createDate
     */
    public Date getCreateDate() {
        return createDate;
    }

    /**
     * @return the lastOperatorId
     */
    public Long getLastOperatorId() {
        return lastOperatorId;
    }

    /**
     * @return the lastModifyDate
     */
    public Date getLastModifyDate() {
        return lastModifyDate;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param facilityDistance the facilityDistance to set
     */
    public void setFacilityDistance(BigDecimal facilityDistance) {
        this.facilityDistance = facilityDistance;
    }

    /**
     * @param shipmentCycle the shipmentCycle to set
     */
    public void setShipmentCycle(Integer shipmentCycle) {
        this.shipmentCycle = shipmentCycle;
    }
    
    /**
     * @param organization the organization to set
     */
    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

    /**
     * @param fromLoadPlace the fromLoadPlace to set
     */
    public void setFromLoadPlace(LoadPlace fromLoadPlace) {
        this.fromLoadPlace = fromLoadPlace;
    }

    /**
     * @param toLoadPlace the toLoadPlace to set
     */
    public void setToLoadPlace(LoadPlace toLoadPlace) {
        this.toLoadPlace = toLoadPlace;
    }

    /**
     * @param creatorId the creatorId to set
     */
    public void setCreatorId(Long creatorId) {
        this.creatorId = creatorId;
    }

    /**
     * @param createDate the createDate to set
     */
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    /**
     * @param lastOperatorId the lastOperatorId to set
     */
    public void setLastOperatorId(Long lastOperatorId) {
        this.lastOperatorId = lastOperatorId;
    }

    /**
     * @param lastModifyDate the lastModifyDate to set
     */
    public void setLastModifyDate(Date lastModifyDate) {
        this.lastModifyDate = lastModifyDate;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }
}
